package com.cmy.framework.room.dao

import android.util.Log
import java.lang.reflect.ParameterizedType

/**
 * @name:
 *  SqlQuery
 * @package:
 *  com.cmy.framework.room
 * @date:
 *  2023/4/2611:36
 * @author
 *    cmy
 * @description
 *
 */
abstract class SqlQuery {

    /**
     * 对应的表名
     */
    protected val tableName : String
        get(){
            val clazz = (javaClass.superclass.genericSuperclass as ParameterizedType)
                .actualTypeArguments[0] as Class<*>
            val tableName = clazz.simpleName
            Log.d("Dao",tableName)
            return tableName
        }

    /**
     * 查询所有的字符串
     */
    fun sqlSelectAll():String{
        return "SELECT * FROM $tableName "
    }

    /**
     * 删除表对应的SQL语句
     */
    fun sqlDeleteAll():String{
        return "DELETE FROM $tableName"
    }


    fun sqlSelectSing(key:String,value :String ):String{
        return "SELECT * FROM $tableName WHERE $key = $value"
    }

}